<div class="panel panel-default panel-intro">
    <div class="panel-body">
        <div id="" class="tab-content">
            <div class="tab-pane fade active in" id="one">
                <div class="widget-body no-padding">
                    <div class="bootstrap-table">
                        <div class="fixed-table-toolbar">
                            <div class="bs-bars pull-left">
                                <div id="toolbar" class="toolbar" style="position: relative;">
                                    <a href="/admin/product/chargeable_add?pid={$pid}&fid={$fid}&type=0" class="btn btn-success btn-add " title="添加">
                                        <i class="fa fa-plus"></i>
                                        添加
                                    </a>
                                </div>

                            </div>
                            <form action="" method="post">
                                <table  class="table table-striped table-bordered table-hover table-nowrap" data-operate-edit="1" data-operate-del="1" width="100%" border="1">
                                    <thead>
                                    <tr>
                                        <th style="text-align: center; vertical-align: middle;width:4.5%;" data-field="id">
                                            <div class="th-inner ">ID</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:5%;" data-field="title">
                                            <div class="th-inner ">父级名称</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:15%;" data-field="title">
                                            <div class="th-inner ">所属层级</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: left; vertical-align: middle;width:15%;" data-field="title">
                                            <div class="th-inner ">显示标题</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width:6%;" data-field="status">
                                            <div class="th-inner ">显示类型</div>
                                            <div class="fht-cell"></div>
                                        </th>

                                        <th style="text-align: center; vertical-align: middle;width: 10%;" data-field="operate">
                                            <div class="th-inner ">计量单位</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width: 10%;" data-field="operate">
                                            <div class="th-inner ">状态</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                        <th style="text-align: center; vertical-align: middle;width: 20%;" data-field="operate">
                                            <div class="th-inner ">操作</div>
                                            <div class="fht-cell"></div>
                                        </th>
                                    </tr>
                                    </thead>
                                    <tbody data-listidx="0">
                                    {volist name="list" id="vo"}
                                    <tr>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$vo.id}
                                        </td>
                                        <td style=" text-align: center; vertical-align: middle;">
                                            {$vo.fid_name}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$self_type[$vo['pptype']]}
                                        </td>
                                        <td style="text-align: left; vertical-align: middle; ">
                                            <?php if($vo['level']>0){echo "|".str_repeat('-', $vo['level']*8);} ?>
                                            {$vo.title}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {if condition="$vo.selecttype eq 1"}
                                                多选
                                            {elseif condition="$vo.selecttype eq 2" /}
                                                单选
                                            {/if}

                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {$vo.unit}
                                        </td>
                                        <td style="text-align: center; vertical-align: middle; ">
                                            {if condition="$vo.status eq 1"}正常{else/}下线{/if}
                                        </td>
                                        <td style="text-align: left; vertical-align: middle; ">

                                            {if condition="$vo.pptype eq 0"}
                                            <a href="javascript:;" onclick="chargeable_copy('{$vo.id}','{$vo.pptype}');" class="btn btn-success btn-add " title="自费项目复制">
                                                <i class="fa fa-plus"></i>
                                                自费项目复制
                                            </a>
                                            {/if}
                                            {if condition="$vo['pptype'] lt 3"}
                                                    {if condition="$vo['pptype'] eq 2"}
                                                    <a href="javascript:;" onclick="chargeable_zyx_add('{$vo.id}','{$vo.selecttype}');" class="btn btn-success btn-add " title="选择自由行产品">
                                                        <i class="fa fa-plus"></i>
                                                        选择自由行产品
                                                    </a>
                                                    {else/}
                                                    <a href="/admin/product/chargeable_add?pid={$pid}&fid={$vo['id']}&type={$vo['pptype']+1}" class="btn btn-success btn-add " title="添加子节点">
                                                        <i class="fa fa-plus"></i>
                                                        添加子节点
                                                    </a>
                                                    {/if}
                                            {/if}
                                            {if condition="$vo['pptype'] eq 3"}
                                                <a href="/admin/product/chargeable_edit_price?id={$vo.id}&pricetype={$vo.pricetype}" class="btn btn-success btn-edit btn-disabled" title="价格维护">
                                                    <i class="fa fa-pencil"></i>
                                                    价格维护
                                                </a>
                                                <a href="javascript:;"  onclick="chargeable_del_price('{$vo.id}');"    class="btn btn-success btn-del" title="删除">
                                                    <i class="fa fa-trash"></i>
                                                    删除
                                                </a>
                                            {else/}
                                            <a href="/admin/product/chargeable_edit?id={$vo.id}" class="btn btn-success btn-edit btn-disabled" title="编辑">
                                                <i class="fa fa-pencil"></i>
                                                修改
                                            </a>
                                            <a href="javascript:;"  onclick="chargeable_del('{$vo.id}');"    class="btn btn-success btn-del" title="删除">
                                                <i class="fa fa-trash"></i>
                                                删除
                                            </a>
                                            {/if}

                                        </td>
                                    </tr>
                                    {/volist}
                                    </tbody>
                                </table>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
</div>

<script>
    function chargeable_del(id){
        $.ajax({
            type:'post',
            dataType:'json',
            url:'/admin/product/chargeable_del',
            data:{"id":id},
            success:function(data){
                if(data.status==1){
                    alert(data.message);
                    location.reload();
                }else{
                    alert(data.message);
                }

            }
        })

    }

    function chargeable_del_price(id){
        $.ajax({
            type:'post',
            dataType:'json',
            url:'/admin/product/chargeable_del_price',
            data:{"id":id},
            success:function(data){
                if(data.status==1){
                    alert(data.message);
                    location.reload();
                }else{
                    alert(data.message);
                }

            }
        })
    }

    function chargeable_zyx_add(id,flag){
        if(flag==1){
            $.ajax({
                type:'post',
                dataType:'json',
                url:'/admin/product/chargeable_zyx_add',
                data:{"id":id},
                success:function(data){
                    if(data.status==1){
                        layer.open({
                            type: 2,
                            title:"选择自由行产品",
                            shift: 2,
                            area: ['60%', '100%'],
                            content: ['chargeable_zyx_list?id='+id],
                            scrollbar: true ,//屏蔽浏览器滚动条
                        });
                    }else{
                        alert(data.message);
                    }
                }
            })
        }else{

            layer.open({
                type: 2,
                title:"选择自由行产品",
                shift: 2,
                area: ['60%', '100%'],
                content: ['chargeable_zyx_list?id='+id],
                scrollbar: true ,//屏蔽浏览器滚动条
            });

        }

    }



    function chargeable_copy(id,pptype){
        if(pptype!=0){
            alert("只能复制顶级自费项目");
            return;
        }
        $.ajax({
            type:'post',
            data:{'id':id},
            url:'/admin/product/chargeable_copy',
            dataType:'json',
            success:function(data){
                if(data.status==1){
                    alert(data.message);
                    location.reload();
                }
            }
        })


    }
</script>


